On macOS we can add labels directly to SwiftUI slider. Has someone found a way how we can align two or more sliders in a VStack?- label text right aligned- all labels should have the same width (given by the largest text)- all slider bars should have the same but flexible width within the containers frame
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
In the latest beta most of the SwiftUI controls have now a labels that are displayed on the left side of the controls. The alignment of the controls and labels works pretty well. Also the TextField is aligned with the other controls. But its title parameter is used as a placeholder inside the TextField while the left side of the TextField is empty.
In my application I have a SwiftUI form with some controls and some number input fields. After the user has entered values the placeholders are not visible and the user cannot see the meaning of each value he entered anymore.
Is there a way that the title of a TextField can be displayed as a label on the left side similar to the other controls instead of a placeholder inside the input field?
Why is there no label for SwiftUI TextField but only a placeholder text? Or is there a modifier that I haven't found yet or a style property? On macOS every control seems to have now a label that is shown on the left side and that is correctly aligned with the other controls in a form. The TextField is also aligned with the other controls but has an empty space left to it. Using the label parameter as a placeholder is not very helpful having multiple textfields and the user entered already some values in them. In this case you cannot see anymore the meaning for all these values. I tried to implement a HStack with a Text and a TextField as a workaround but had trouble to align it with the other controls that have already label parameters in their SwiftUI syntax.
Is there a way to add a label to SwiftUI Textfield inside a SwiftUI Form so that the label is aligned with the other controls? Placeholder in textfields will disappear when you enter values so this won't help much.
All other controls have labels in macOS form with the same width so that their controls are correctly aligned. Textfield seems not to have this option. I tried several workaround like HStacks of Text and Textfields or custom alignment guides but without success.
Above Xcode's navigator area or uitilty area there are some buttons for switching the content views below. I implemented the standard SwiftUI TabView and also a Picker with the segmented style to get the same appearance in my macOS app but both are looking different.
Plain buttons in a HStack above my content area are solving the problem. But it seems more like a workaround. Is there maybe a simpler solution to implement a Xcode style tabview that I have overseen.
Is there a way to add separators to SwiftUI toolbar so that when you change the size of a splitview segment all the toolbar buttons will stay aligned with this segment? Or does it only work without SwiftUI?
Can someone help me with this hopefully simple problem? I use triple buffering in my metal app similar to Apples Best Practice Guide.
Three threads are simultaneously encoding rendering commands to command buffers enqueued in into one MTLCommandQueue.
What is the best way to debug this scenario with the Xcode's frame debugger? I have some problems setting the capture scopes begin and end point in such a multithreaded environment to isolate the commands encoded from one thread.
My app uses an external PCI board connected with the thunderbolt cable to a 2019 MacBook Pro (Big Sur beta 10). The strange thing is that the external example apps coming with the driver can communicate with it. The same apps compiled with Xcode 12.2 beta cannot communicate with the driver even it is the same code.
When I installed the driver together with the example apps a window appeared that these software come from an external source and the usage must be granted in the security settings. I did it and therefor the apps work fine.
Is there maybe a similar setting now in Xcode where I must allow the compiled app to communicate with third party drivers? The code of the app was unchanged and worked with a previous macOS version.
I struggle with the implementation of a compute kernel to solve a relative simple search problem. I want to find the coordinate with the highest pixel value within a MTLTexture.
I have already an implementation where I copy the content of the MTLTexture into CPU memory and apply some min/max commands from the accelerate framework. But maybe there is also a simple solution for this task using Metal which I haven't found yet.
Is it possible to use the new http traffic instrument with combines dataTaskPublisher? How can I set a label to the task?
I have two Mac Book Pro 16'' 2019. On both I see a very high battery drain using Xcode 13 while using the simulator. Even when the app is not running only the simulator is launched in the background the MacBook gets very hot and the battery drains empty very fast.
For the beta this was ok. But with the RC I expected that this was only a temporary problem. Does some else has this problem also?
I found this problem many times in the internet but not a solution for this.
I have a SwiftUI list with data fetched from a server. The app uses a periodically background sync (into a core data background context). So the rows of this list can change. To make it simple to understand think of a message app like on the iPhone:
struct MasterView: View {
@FetchRequest(
sortDescriptors: [NSSortDescriptor(keyPath: \Chat.name, ascending: true)],
animation: .none)
private var chats: FetchedResults<Chat>
var body: some View {
List {
ForEach(chats, id: \.chatID) { chat in
NavigationLink(destination: DetailView(chat: chat)) {
Text(chat.name ?? "")
}
}
}
}
}
The detail view is not so important here but keeping with the example of a message app you would have something like the following code to display the messages of a selected chat:
struct DetailView: View {
let chat: Chat
@FetchRequest(
sortDescriptors: [NSSortDescriptor(keyPath: \Message.timestamp, ascending: true)],
animation: .none)
private var messages: FetchedResults<Message>
var body: some View {
List {
ForEach(messages, id: \.messageID) { message in
Text(message.messageText ?? "")
}
}
.onAppear {
if let chatID = chat.chatID {
messages.nsPredicate = NSPredicate(format: "chatID == %@", chatID)
}
}
}
}
In the internet I saw also other examples without using core data for the master view.
If the details view is visible to the user and the master view receives new data from the server the details view will always close (pops) automatically. This happens also when the chatID has not changed and still exists. A change of the master or also if in a split view the master view scrolls outside the visible area then the detail screen will close.
As you see I specified the item ids in both ForEach lists and added also in some further tests identifiers to the NavigationLink or destination of the NavigationLink. But as soon the master list updates the old NavigationLink seems to get deallocated and therefore the detail views will close.
Does someone know how to fix this? Of course I could add a button inside the masters list, store the selection and place the NavigationLink outside from the list item as I saw in one example, but it seems to be more a quick hack as a good solution.
I am able to insert, delete or replace items in the macOS menu bar using SwiftUIs CommandGroup command. Is it also possible to rename an existing menu title?
My goal is to replace the 'file' menu title with 'account'.
The rest of the menu bar can stay as it is.
Maybe I misunderstood the the 2019 WWDC video 'Making apps with core data'. Because when I use NSBatchInsertRequest together with NSMergeByPropertyObjectTrumpMergePolicy and unique constraints I can only add new records with the given id. Existing core data objects will not be partially updated.
Example Entity: Person
Attributes:
FirstName = John
LastName = Appleseed
ID = 1234 (unique constraint)
Goal in this example should be to change only the FirstName.
As far as I understood the session video we can omit some attributes and call NSBatchInsertRequest with the above ID and change FirstName to 'Johnny'. But this seems not to work.
Maybe someone has an idea if I am doing something wrong here or if this is really not possible to omit values and change single attribute values.
I want to avoid fetching existing records, updating the values that should be changed and committing the changes back to the persistent store if there is maybe a better solution.
I have a simple SwiftUI List view with a .toolbar modifier containing three ToolbarItems. The placement is set to bottom.
On the iPhone it seems as if the toolbar is animating from the bottom right corner whenever I launch the app. Having this view as a destination view it looks really strange. The NavigationLink causes the List view to appear from the right while the toolbar slides in from the bottom right corner.
Is there a way to make the bottom toolbar not to slide it from the corner?